﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TeamBuy.AccessWebUI
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["ID"] == "" || Request.QueryString["ID"] == null)
            {
                Main_DealDetail1.ShowTodayDeal();
                Side_SameDayDeal1.SelectCommand = "SELECT * FROM [S_Deal] WHERE #" + DateTime.Now + "# BETWEEN DateStarted and DateEnded AND IsCurrentDeal = Yes AND IsTodayMainDeal = No AND CityID = " + ((Components.Head)(Page.Master.Master.FindControl("Head1"))).CurrentCityID;
            }
            else
            {
                Main_DealDetail1.ShowDealByID(Convert.ToInt32(Common.PublicFunction.DESDecrypt(Request.QueryString["ID"].ToString())));
                Side_SameDayDeal1.SelectCommand = "SELECT * FROM [S_Deal] WHERE #" + DateTime.Now + "# BETWEEN DateStarted and DateEnded AND IsCurrentDeal = Yes AND IsTodayMainDeal = Yes AND CityID = " + ((Components.Head)(Page.Master.Master.FindControl("Head1"))).CurrentCityID;
            }
            int currentDealStatus = Main_DealDetail1.GetCurrentDealStatus();
            if (currentDealStatus == 2 || currentDealStatus == 3)
            {
                Main_SoldoutTip1.Visible = true;
            }
            Page.Title = Main_DealDetail1.GetCurrentDealTitle() + " - " + TeamBuy.AccessService.TeamBuySystemInfo.SiteName;
        }
    }
}